package com.halflife.framework.generator.template.mapper;

/**
 * Created by zhaoyf on 2018/6/18.
 */
public class UpdateAnalysis extends BaseAnalysis {
    public UpdateAnalysis(Class clazz) {
        super(clazz);
    }

    @Override
    protected void setPrefix() {
        this.xmlStr.append("<update id=\"updateByPrimaryKey\"  parameterType=\""+this.clazz.getName()+"\">\n");
        this.xmlStr.append("\t update `"+this.tableName+"` set");

    }


    @Override
    protected String getValue1(CustomField customField) {
        if (!customField.isPersist()) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        sb.append(customField.getName());
        sb.append(" = #{");
        sb.append(customField.getName());
        sb.append(",jdbcType=").append(customField.getTypeName()).append("}");
        sb.append("  ");
        return sb.toString();
    }



    ;

    protected void setSuffix() {
        this.xmlStr.append(" where id = #{id,jdbcType=INTEGER} \n");
        this.xmlStr.append( "</update>");
    }

    ;
}
